package net.zdsoft.wpchat.support.service;

import java.util.List;
import java.util.Map;
import java.util.Set;

import net.zdsoft.wpchat.support.dto.OperatorDto;
import net.zdsoft.wpchat.support.entity.AuthConfig;
import net.zdsoft.wpchat.support.entity.AuthGroup;
import net.zdsoft.wpchat.support.entity.AuthGroupUser;
import net.zdsoft.wpchat.support.entity.GroupPermission;
import net.zdsoft.wpchat.support.entity.Operator;
import net.zdsoft.wpchat.support.entity.UserConfig;

/**
 * 权限Service
 * 
 * @author xuan
 * @version $Revision: 1.0 $, $Date: 2014-9-22 下午10:45:17 $
 */
public interface AuthService {
    /**
     * 获得用户授权信息
     * 
     * @param operatorId
     * @return
     */
    UserConfig getUserConfig(String operatorId);

    /**
     * 获得用户列表
     * 
     * @param groupIds
     * @return
     */
    List<Operator> getOperatorsByGroupIds(String operatorId, String... groupIds);

    /**
     * 获得所有用户组
     * 
     * @return
     */
    List<AuthGroup> getAllGroup(String operatorId);

    /**
     * 得到所有权限信息
     * 
     * @return
     */
    AuthConfig getAuthConfig(String operatorId);

    /**
     * 查找某个组的权限
     * 
     * @param groupIds
     * @return
     */
    List<GroupPermission> getGroupPerms(String... groupIds);

    /**
     * 获得指定组的MAP
     * 
     * @param groupId
     * @return
     */
    Map<String, GroupPermission> getOperationId2GroupPermMap(String groupId);

    /**
     * 修改权限
     * 
     * @param groupId
     * @param catalogId
     * @param groupPerms
     */
    void modifyGroupPerms(String groupId, String catalogId, GroupPermission... groupPerms);

    /**
     * 冻结帐号
     * 
     * @param operatorId
     */
    void freezeOperator(String operatorId);

    /**
     * 解冻帐号
     * 
     * @param operatorId
     */
    void unfreezeOperator(String operatorId);

    /**
     * 删除授权运营商
     * 
     * @param operatorId
     * @param cooperatorIds
     */
    void removeAuthCooperator(String operatorId, Integer... cooperatorIds);

    /**
     * 根据帐号ID，获取已经授权的运营商ID
     * 
     * @param operatorId
     * @return
     */
    Set<Integer> getAuthCooperatorIds(String operatorId);

    /**
     * 根据帐号ID，获取已经授权的运营商ID
     * 
     * @param operatorIds
     * @return
     */
    Map<String, Set<Integer>> getAuthCooperatorIds(String... operatorIds);

    void modifyPassword(String operatorId, String password);

    void addGroup(AuthGroup authGroup);

    void modifyGroup(AuthGroup authGroup);

    void removeGroup(String... groupIds);

    void removeOperator(String operatorId);

    void addOperator(OperatorDto dto);

    void modifyOperator(OperatorDto dto);

    OperatorDto getOperatorById(String operatorId);

    Map<String, AuthGroup> getAllGroupMap();

    Map<String, List<AuthGroupUser>> getGroupUsers();

    /**
     * 复制学校授权信息
     * 
     * @param srcOperId
     *            源操作员ID
     * @param clearDesAuth
     *            是否清空目标操作员已有的学校授权
     * @param desOperIds
     *            目标操作员ID
     */
    void copyAuthCooperator(String srcOperId, boolean clearDesAuth, String... desOperIds);

}
